﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:Fluent="clr-namespace:Fluent"
                    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
                    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
                    mc:Ignorable="d">
    <ControlTemplate TargetType="{x:Type Fluent:RibbonTabItem}" x:Key="RibbonTabItemControlTemplate">
        <Grid x:Name="grid" Background="#00000000" Height="24" VerticalAlignment="Top" Margin="0,7,0,0">
            <Border x:Name="border3" Margin="2,0,0,1" Grid.ColumnSpan="2">
                <Border x:Name="border5"
                        Background="{Binding Group.Background, RelativeSource={RelativeSource TemplatedParent}}"
                        BorderThickness="0,0,0,0" Margin="0,0,0,0">
                    <Border.OpacityMask>
                        <LinearGradientBrush EndPoint="0.5,1"
                                             StartPoint="0.5,0">
                            <GradientStop Color="#26000000"
                                          Offset="0" />
                            <GradientStop Color="#26000000"
                                          Offset="1" />
                        </LinearGradientBrush>
                    </Border.OpacityMask>
                </Border>
            </Border>
            <Grid x:Name="selectedGrid"
                  Visibility="Collapsed"
                  Margin="2,0,0,0"
                  Grid.ColumnSpan="1">
                <Rectangle x:Name="rectangle" Fill="{DynamicResource ActiveTabBackgroundBrush}" StrokeThickness="0"
                           Margin="0" VerticalAlignment="Bottom" Height="1" />
                <Rectangle x:Name="rectangle1" Fill="{DynamicResource ActiveTabBackgroundBrush}"
                           StrokeThickness="0" Margin="1.8,0"
                           VerticalAlignment="Bottom"
                           Height="1.2" />
                <Rectangle x:Name="rectangle2"
                           Fill="{DynamicResource ActiveTabBackgroundBrush}"
                           StrokeThickness="0"
                           Margin="2,0"
                           VerticalAlignment="Bottom"
                           Height="2" />
                <Border x:Name="border" Margin="1,0,1,2" BorderBrush="{DynamicResource RibbonTopBorderBrush}"
                        BorderThickness="1,1,1,0"
                        VerticalAlignment="Stretch" Background="{DynamicResource ActiveTabBackgroundBrush}">
                    <Border x:Name="border_Copy3"
                            Margin="0"
                            BorderThickness="1,1,1,0"
                            VerticalAlignment="Stretch"
                            CornerRadius="2,2,0,0"
                            BorderBrush="{DynamicResource ActiveTabBackgroundBrush}">
                    </Border>
                </Border>
                <!--<Border x:Name="border1" HorizontalAlignment="Left" Margin="0" VerticalAlignment="Bottom" Width="2" Height="2"
                                    BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="0,0,1,1"/>-->
                <Border x:Name="border1" HorizontalAlignment="Left" Margin="0" VerticalAlignment="Bottom" Width="2"
                        Height="2"
                        BorderBrush="{DynamicResource RibbonTopBorderBrush}" BorderThickness="0,0,1,1" />
                <Border x:Name="border2" HorizontalAlignment="Right" Margin="0" VerticalAlignment="Bottom" Width="2"
                        Height="2"
                        BorderBrush="{DynamicResource RibbonTopBorderBrush}" BorderThickness="1,0,0,1" />
            </Grid>
            <Grid x:Name="focusedGrid"
                  Margin="2,0,0,0"
                  Visibility="Collapsed"
                  Grid.ColumnSpan="1">
                <Grid.OpacityMask>
                    <LinearGradientBrush EndPoint="0.5,1"
                                         StartPoint="0.5,0">
                        <GradientStop Color="White"
                                      Offset="0" />
                        <GradientStop Offset="1"
                                      Color="#19FFFFFF" />
                    </LinearGradientBrush>
                </Grid.OpacityMask>
                <Border x:Name="border_Copy5"
                        Margin="1,0,1,1"
                        BorderThickness="1,1,1,0"
                        VerticalAlignment="Stretch"
                        CornerRadius="2,2,0,0"
                        Background="{DynamicResource ButtonHoverOuterBackgroundBrush}"
                        BorderBrush="{DynamicResource ButtonHoverOuterBorderBrush}">
                    <Border x:Name="border_Copy6"
                            Margin="0"
                            BorderBrush="{DynamicResource ButtonHoverInnerBorderBrush}"
                            BorderThickness="1,1,1,0"
                            VerticalAlignment="Stretch"
                            CornerRadius="2,2,0,0"
                            Background="{DynamicResource ButtonHoverInnerBackgroundBrush}" />
                </Border>
            </Grid>
            <Border x:Name="PART_ContentContainer"
                    HorizontalAlignment="Stretch"
                    Margin="6,2,4,0"
                    VerticalAlignment="Stretch"
                    Padding="15,0,0,0"
                    Grid.ColumnSpan="1">
                <!--<ContentPresenter x:Name="contentPresenter" ContentSource="Header" HorizontalAlignment="Center" VerticalAlignment="Center" Height="Auto"/>-->
                <Label x:Name="contentPresenter"
                       AutomationProperties.Name="{TemplateBinding Header}"
                       AutomationProperties.AutomationId="{TemplateBinding Name}"
                       Content="{TemplateBinding Header}"
                       Margin="0, -4, 0,-1"
                       HorizontalAlignment="Center"
                       VerticalAlignment="Center"
                       Height="Auto" />
            </Border>
            <Grid x:Name="separatorGrid"
                  Margin="0"
                  Visibility="Collapsed"
                  HorizontalAlignment="Right"
                  Width="2"
                  Grid.Column="1">
                <Rectangle x:Name="separatorRectangle1"
                           Fill="{DynamicResource RibbonTopBorderBrush}"
                           Stroke="{DynamicResource RibbonTopBorderBrush}"
                           Margin="0,0,1,0"
                           HorizontalAlignment="Right"
                           Width="1"
                           Opacity="1"
                           Visibility="Visible">
                    <Rectangle.OpacityMask>
                        <LinearGradientBrush EndPoint="0.5,1"
                                             StartPoint="0.5,0">
                            <GradientStop Color="#00000000"
                                          Offset="0" />
                            <GradientStop Color="#E5FFFFFF"
                                          Offset="0.382" />
                        </LinearGradientBrush>
                    </Rectangle.OpacityMask>
                </Rectangle>
                <Rectangle x:Name="separatorRectangle2"
                           Fill="{DynamicResource ActiveTabBackgroundBrush}"
                           Stroke="{DynamicResource ActiveTabBackgroundBrush}"
                           HorizontalAlignment="Right"
                           Margin="0"
                           Width="1"
                           Opacity="1"
                           Visibility="Visible">
                    <Rectangle.OpacityMask>
                        <LinearGradientBrush EndPoint="0.5,1"
                                             StartPoint="0.5,0">
                            <GradientStop Color="#00000000"
                                          Offset="0" />
                            <GradientStop Color="#BFFFFFFF"
                                          Offset="0.329" />
                        </LinearGradientBrush>
                    </Rectangle.OpacityMask>
                </Rectangle>
            </Grid>
        </Grid>
        <ControlTemplate.Triggers>
            <Trigger Property="IsEnabled"
                     Value="False">
                <Setter Property="Opacity"
                        TargetName="contentPresenter"
                        Value="0.5" />
            </Trigger>
            <MultiTrigger>
                <MultiTrigger.Conditions>
                    <Condition Property="HasRightGroupBorder"
                               Value="False" />
                    <Condition Property="HasLeftGroupBorder"
                               Value="True" />
                </MultiTrigger.Conditions>
                <Setter Property="Margin"
                        TargetName="border5"
                        Value="1,0,-1,0" />
            </MultiTrigger>
            <MultiTrigger>
                <MultiTrigger.Conditions>
                    <Condition Property="HasLeftGroupBorder"
                               Value="False" />
                    <Condition Property="HasRightGroupBorder"
                               Value="True" />
                </MultiTrigger.Conditions>
                <Setter Property="Margin"
                        TargetName="border5"
                        Value="-1,0,1,0" />
            </MultiTrigger>
            <MultiTrigger>
                <MultiTrigger.Conditions>
                    <Condition Property="HasLeftGroupBorder"
                               Value="False" />
                    <Condition Property="HasRightGroupBorder"
                               Value="False" />
                </MultiTrigger.Conditions>
                <Setter Property="Margin"
                        TargetName="border5"
                        Value="-1,0,-1,0" />
            </MultiTrigger>
            <MultiTrigger>
                <MultiTrigger.Conditions>
                    <Condition Property="HasLeftGroupBorder"
                               Value="True" />
                    <Condition Property="HasRightGroupBorder"
                               Value="True" />
                </MultiTrigger.Conditions>
                <Setter Property="Margin"
                        TargetName="border5"
                        Value="1,0,1,0" />
            </MultiTrigger>
            <Trigger Property="Group"
                     Value="{x:Null}">
                <Setter Property="Visibility"
                        TargetName="border3"
                        Value="Collapsed" />
                <Setter Property="Margin"
                        TargetName="separatorGrid"
                        Value="-1,0,0,1" />
                <Setter Property="Visibility"
                        TargetName="border_Copy3"
                        Value="Collapsed" />
            </Trigger>
            <MultiTrigger>
                <MultiTrigger.Conditions>
                    <Condition Property="Selector.IsSelected"
                               Value="True" />
                    <Condition Property="IsMinimized"
                               Value="False" />
                </MultiTrigger.Conditions>
                <Setter Property="Visibility"
                        TargetName="selectedGrid"
                        Value="Visible" />
                <Setter Property="Foreground"
                        TargetName="contentPresenter"
                        Value="{Binding Group.Background, RelativeSource={RelativeSource TemplatedParent}}" />
            </MultiTrigger>
            <MultiTrigger>
                <MultiTrigger.Conditions>
                    <Condition Property="Selector.IsSelected"
                               Value="True" />
                    <Condition Property="IsMinimized"
                               Value="False" />
                    <Condition Property="Group"
                               Value="{x:Null}" />
                </MultiTrigger.Conditions>
                <Setter Property="Visibility"
                        TargetName="selectedGrid"
                        Value="Visible" />
                <Setter Property="Foreground"
                        TargetName="contentPresenter"
                        Value="{Binding RibbonThemeColor, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Fluent:MetroWindow}}}" />
            </MultiTrigger>
            <MultiTrigger>
                <MultiTrigger.Conditions>
                    <Condition Property="IsMouseOver"
                               Value="True" />
                    <Condition Property="Selector.IsSelected"
                               Value="False" />
                    <Condition Property="IsMinimized"
                               Value="False" />
                </MultiTrigger.Conditions>
                <Setter Property="Foreground"
                        TargetName="contentPresenter"
                        Value="{Binding Group.Background, RelativeSource={RelativeSource TemplatedParent}}" />
            </MultiTrigger>
            <MultiTrigger>
                <MultiTrigger.Conditions>
                    <Condition Property="IsMouseOver"
                               Value="True" />
                    <Condition Property="Selector.IsSelected"
                               Value="False" />
                    <Condition Property="IsMinimized"
                               Value="False" />
                    <Condition Property="Group"
                               Value="{x:Null}" />
                </MultiTrigger.Conditions>
                <Setter Property="Foreground"
                        TargetName="contentPresenter"
                        Value="{Binding RibbonThemeColor, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Fluent:MetroWindow}}}" />
            </MultiTrigger>
            <MultiTrigger>
                <MultiTrigger.Conditions>
                    <Condition Property="IsMouseOver"
                               Value="True" />
                    <Condition Property="IsMinimized"
                               Value="True" />
                    <Condition Property="IsOpen"
                               Value="False" />
                </MultiTrigger.Conditions>
                <Setter Property="Foreground"
                        TargetName="contentPresenter"
                        Value="{Binding RibbonThemeColor, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Fluent:MetroWindow}}}" />
            </MultiTrigger>
            <MultiTrigger>
                <MultiTrigger.Conditions>
                    <Condition Property="Selector.IsSelected"
                               Value="True" />
                    <Condition Property="IsMinimized"
                               Value="True" />
                    <Condition Property="IsOpen"
                               Value="True" />
                </MultiTrigger.Conditions>
                <Setter Property="Background"
                        TargetName="grid"
                        Value="#00000000" />
                <Setter Property="Foreground"
                        TargetName="contentPresenter"
                        Value="{Binding Group.Background, RelativeSource={RelativeSource TemplatedParent}}" />
            </MultiTrigger>
            <Trigger Property="IsSeparatorVisible"
                     Value="True">
                <Setter Property="Visibility"
                        TargetName="separatorGrid"
                        Value="Visible" />
                <Setter Property="Margin"
                        TargetName="PART_ContentContainer"
                        Value="6,2,6,0" />
                <Setter Property="Margin"
                        TargetName="selectedGrid"
                        Value="2,0" />
            </Trigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>

    <Style x:Key="RibbonTabItemStyle"
           TargetType="{x:Type Fluent:RibbonTabItem}">
        <Style.Triggers>
            <Trigger Property="Group"
                     Value="{x:Null}">
                <Setter Property="BorderBrush"
                        Value="{DynamicResource RibbonTopBorderBrush}" />
            </Trigger>
            <Trigger Property="Selector.IsSelected"
                     Value="False">
                <Setter Property="Foreground"
                        Value="{DynamicResource TabItemFontBrush}" />
            </Trigger>
        </Style.Triggers>
        <Setter Property="HorizontalAlignment"
                Value="Left" />
        <Setter Property="VerticalAlignment"
                Value="Top" />
        <Setter Property="Height"
                Value="31" />
        <Setter Property="IsMinimized"
                Value="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Fluent:RibbonTabControl}}, Path=IsMinimized, Mode=OneWay, FallbackValue=False}" />
        <Setter Property="IsOpen"
                Value="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Fluent:RibbonTabControl}}, Path=IsDropDownOpen, Mode=OneWay, FallbackValue=True}" />
        <Setter Property="Template" Value="{StaticResource RibbonTabItemControlTemplate}" />
        <Setter Property="IsTabStop"
                Value="False" />
        <Setter Property="Indent"
                Value="12" />
        <Setter Property="Foreground"
                Value="{DynamicResource TabItemSelectedFontBrush}" />
        <Setter Property="FontFamily"
                Value="{DynamicResource DefaultFontFamily}" />
        <Setter Property="FontSize"
                Value="{DynamicResource DefaultFontSize}" />
        <Setter Property="Margin"
                Value="0" />
        <Setter Property="BorderBrush"
                Value="{DynamicResource RibbonTopBorderBrush}" />
        <Setter Property="FocusVisualStyle"
                Value="{DynamicResource ControlStyleEmptyFocus}" />
    </Style>
</ResourceDictionary>